<template>
  <c-card isNone isAffix>
    <div class="user-details">
      <el-tabs v-model="activeName">
        <el-tab-pane label="基础信息" name="basics">
          <ul class="user-info-box">
            <li><span>用户名：</span>{{ userStore?.userInfo?.username }}</li>
            <li><span>剩余积分：</span>{{ userStore?.userInfo?.miniData?.score }}</li>
            <li>
              <span>注册时间：</span>
              {{ dayjs(userStore?.userInfo?.register_date).format('YYYY-MM-DD HH:mm:ss') }}
            </li>
            <li>
              <span>已关联小程序：</span>
              <div class="user-info-mini">
                <div class="mini-item">
                  <img :src="userStore?.userInfo?.miniData?.avatar" alt="" />
                  <div class="mini-item-right">
                    <span>{{ userStore?.userInfo?.miniData?.nickname }}</span>
                    <span class="mini-item-id">ID：{{ userStore?.userInfo?.miniData?._id }}</span>
                  </div>
                </div>
              </div>
            </li>
          </ul>
        </el-tab-pane>
        <!-- <el-tab-pane label="安全设置" name="second">安全设置</el-tab-pane>
        <el-tab-pane label="权限分配" name="third">权限分配</el-tab-pane> -->
      </el-tabs>
    </div>
  </c-card>
</template>

<script setup name="system.user">
import { ref } from 'vue';
import dayjs from 'dayjs';
import { hidePhone } from '@/utils/tools.js';

// user
import { useUserStore } from '@/pinia/modules/user.js';
const userStore = useUserStore();

console.log(userStore?.userInfo, 'userStore?.userInfo');

const activeName = ref('basics');
</script>

<style lang="scss" scoped>
.user-info {
  @include card-box;
  padding: 16px 30px;
  display: flex;
  align-items: center;
  flex-direction: row;
  height: 80px;
  margin-bottom: 16px;

  & > img {
    width: 80px;
    aspect-ratio: 1/1;
    border-radius: 50%;
    flex-shrink: 0;
    box-sizing: border-box;
    border: 1px solid var(--el-border-color);
  }

  &-list {
    list-style-type: none;
    font-size: 14px;
    min-width: 260px;
    margin-right: 10px;
    height: 100%;
    display: flex;
    flex-flow: row wrap;
    align-content: space-around;

    & > li {
      width: 100%;
      display: flex;
      line-height: 1.5;

      & > span {
        width: 100px;
        text-align: right;
        margin-right: 6px;
      }
    }
  }
}

.user-info-box {
  list-style-type: none;
  font-size: 14px;
  height: 100%;
  margin-left: 0;
  padding-left: 0;

  & > li {
    width: 100%;
    display: flex;
    line-height: 1.8;
    margin: 10px 0;

    & > span {
      width: 100px;
      text-align: right;
    }
  }
}

.user-info-mini {
  background-color: #f5f5f5;
  padding: 12px 26px;
  box-sizing: border-box;
  border-radius: 6px;
  min-width: 200px;
}

.mini-item {
  display: flex;
  align-items: center;

  & > img {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    margin-right: 10px;
  }
}

.mini-item-right {
  display: flex;
  flex-direction: column;
}

.mini-item-id {
  font-size: 12px;
  color: #999;
}

.user-details {
  height: 100%;
  padding: 16px 30px;
  @include card-box;
}
</style>
